package com.example.coursehub.user.dto;

import com.example.coursehub.user.entity.User;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 用户请求相关DTO
 */
public class UserRequestDTO {

    /**
     * 用户注册请求
     */
    public static class RegisterRequest {
        
        @NotBlank(message = "用户名不能为空")
        @Size(max = 100, message = "用户名长度不能超过100个字符")
        private String userName;

        @NotBlank(message = "用户账号不能为空")
        @Size(max = 100, message = "用户账号长度不能超过100个字符")
        private String userAccount;

        @NotBlank(message = "密码不能为空")
        @Size(min = 6, max = 20, message = "密码长度必须在6-20个字符之间")
        private String userPassword;

        private User.UserRole role = User.UserRole.STUDENT;

        // Constructors
        public RegisterRequest() {}

        public RegisterRequest(String userName, String userAccount, String userPassword, User.UserRole role) {
            this.userName = userName;
            this.userAccount = userAccount;
            this.userPassword = userPassword;
            this.role = role;
        }

        // Getters
        public String getUserName() { return userName; }
        public String getUserAccount() { return userAccount; }
        public String getUserPassword() { return userPassword; }
        public User.UserRole getRole() { return role; }

        // Setters
        public void setUserName(String userName) { this.userName = userName; }
        public void setUserAccount(String userAccount) { this.userAccount = userAccount; }
        public void setUserPassword(String userPassword) { this.userPassword = userPassword; }
        public void setRole(User.UserRole role) { this.role = role; }
    }

    /**
     * 用户登录请求
     */
    public static class LoginRequest {
        
        @NotBlank(message = "用户账号不能为空")
        private String userAccount;

        @NotBlank(message = "密码不能为空")
        private String userPassword;

        // Constructors
        public LoginRequest() {}

        public LoginRequest(String userAccount, String userPassword) {
            this.userAccount = userAccount;
            this.userPassword = userPassword;
        }

        // Getters
        public String getUserAccount() { return userAccount; }
        public String getUserPassword() { return userPassword; }

        // Setters
        public void setUserAccount(String userAccount) { this.userAccount = userAccount; }
        public void setUserPassword(String userPassword) { this.userPassword = userPassword; }
    }

    /**
     * 用户更新请求
     */
    public static class UpdateRequest {
        
        @Size(max = 100, message = "用户名长度不能超过100个字符")
        private String userName;

        @Size(min = 6, max = 20, message = "密码长度必须在6-20个字符之间")
        private String userPassword;

        private User.UserRole role;
        private Integer status;

        // Constructors
        public UpdateRequest() {}

        public UpdateRequest(String userName, String userPassword, User.UserRole role, Integer status) {
            this.userName = userName;
            this.userPassword = userPassword;
            this.role = role;
            this.status = status;
        }

        // Getters
        public String getUserName() { return userName; }
        public String getUserPassword() { return userPassword; }
        public User.UserRole getRole() { return role; }
        public Integer getStatus() { return status; }

        // Setters
        public void setUserName(String userName) { this.userName = userName; }
        public void setUserPassword(String userPassword) { this.userPassword = userPassword; }
        public void setRole(User.UserRole role) { this.role = role; }
        public void setStatus(Integer status) { this.status = status; }
    }

    /**
     * 密码修改请求
     */
    public static class ChangePasswordRequest {
        
        @NotBlank(message = "原密码不能为空")
        private String oldPassword;

        @NotBlank(message = "新密码不能为空")
        @Size(min = 6, max = 20, message = "新密码长度必须在6-20个字符之间")
        private String newPassword;

        // Constructors
        public ChangePasswordRequest() {}

        public ChangePasswordRequest(String oldPassword, String newPassword) {
            this.oldPassword = oldPassword;
            this.newPassword = newPassword;
        }

        // Getters
        public String getOldPassword() { return oldPassword; }
        public String getNewPassword() { return newPassword; }

        // Setters
        public void setOldPassword(String oldPassword) { this.oldPassword = oldPassword; }
        public void setNewPassword(String newPassword) { this.newPassword = newPassword; }
    }
}